﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>html5拍照上传头像裁剪</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no, email=no" />
<link href="css/style.css" rel="stylesheet" type="text/css">
<!--[if IE]>
<script src="js/html5shiv.min.js"></script>
<![endif]-->
</head>
<body style="background:#000">

<a href="javascript:void(0);" class="logoBox" id="logoBox">
	<img src="images/userico.jpg" />
	<input id="file" type="file" onchange="javascript:setImagePreview();" accept="image/*"   />
	<!-- multiple -->
</a>

<div class="htmleaf-container">
<div id="clipArea"></div>
<div id="view"></div>
</div>

<div id="dpage">
 <a href="javascript:void(0);" class="qx"><button id="cancleBtn">取消</button></a>
 <a href="javascript:void(0);" class="qx"><button id="clipBtn">确认</button></a>
</div>

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery-2.1.1.min.js"></script>
<script src="js/iscroll-zoom.js"></script>
<script src="js/hammer.js"></script>
<script src="js/jquery.photoClip.js"></script>
<script>
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
$("#clipArea").photoClip({
	width: 280,
	height: 280,
	file: "#file",
	view: "#view",
	ok: "#clipBtn",
	loadStart: function() {
		console.log("照片读取中");
	},
	loadComplete: function() {
		console.log("照片读取完成");
	},
	clipFinish: function(dataURL) {
		console.log(dataURL);
	}
});
$(function(){
	$("#clipBtn").click(function(){
		$("#logoBox").empty();
		$('#logoBox').append('<img src="' + imgsource + '" align="absmiddle" style=" width:100%;">');
		$('#logoBox').append('<input id="file" type="file" onchange="javascript:setImagePreview();" accept="image/*"  />');
		//$('#logoBox').append('<img src="' + imgsource + '" align="absmiddle" style=" width: 5rem;height: 4.16rem; margin-left: 1.5rem;margin-top: 1.92rem">');
		$(".htmleaf-container").hide();
		$("#dpage").removeClass("show");
	});
	$("#cancleBtn").click(function(){
		$(".htmleaf-container").hide();
		$("#dpage").removeClass("show");
	});
});
function setImagePreview() {
	$(".htmleaf-container").fadeIn(300);
	$("#dpage").addClass("show");
}
</script>

</body>
</html>

